package com.lemon.ai.socket.packets.spiritgame.model.main;

import java.util.List;

import com.lemon.ai.socket.packets.spiritgame.model.db.MetaData;
import com.lemon.ai.socket.packets.spiritgame.model.dto.Table;
import com.lemon.ai.socket.packets.spiritgame.model.generator.DaoIfcGenerator;
import com.lemon.ai.socket.packets.spiritgame.model.generator.DaoImplGenerator;
import com.lemon.ai.socket.packets.spiritgame.model.generator.DtoGenerator;
import com.lemon.ai.socket.packets.spiritgame.model.utils.FileUtils;

public class DBDAOParser {

	private static DaoIfcGenerator daoIfcGenerator = new DaoIfcGenerator();
	private static DaoImplGenerator daoImplGenerator = new DaoImplGenerator();
	private static DtoGenerator dtoGenerator = new DtoGenerator();
//	private static FactoryGenerator factoryGenerator = new FactoryGenerator();
//	private static DbUtilsGenerator jdbcUtilsGenerator = new DbUtilsGenerator();
//	private static MappingFileGenerator mfg = new MappingFileGenerator();//表名和类名映射关系类生成器
//	private static KeyUtilGenerator kg = new KeyUtilGenerator();
	
	private static FileUtils fu = new FileUtils();

	public static void main(String[] args) {
		
		System.setProperty("file.encoding", "UTF-8");
		
		MetaData meta = MetaData.getInstance();
		List<Table> tables = meta.getTables();
	//	fu.write(factoryGenerator.generateFileName(), 		factoryGenerator.generate(tables));
	//	fu.write(jdbcUtilsGenerator.generateFileName(), 	jdbcUtilsGenerator.generate());
	//	fu.write(mfg.generateClassName(), 					mfg.generate(tables));
	//	fu.write(kg.generateClassName(), 					kg.generate(tables));
		
		for (int i = 0; i < tables.size(); i++) {
			Table t = tables.get(i);
			fu.write(daoIfcGenerator.generateFileName(t), 	daoIfcGenerator.generate(t));
			fu.write(daoImplGenerator.generateFileName(t), 	daoImplGenerator.generate(t));
			fu.write(dtoGenerator.generateFileName(t), 		dtoGenerator.generate(t));
		}
	}

}
